package scauCmiScaffolding.compiled;

import org.eclipse.jet.JET2Context;
import org.eclipse.jet.JET2Template;
import org.eclipse.jet.JET2Writer;
import org.eclipse.jet.taglib.RuntimeTagElement;
import org.eclipse.jet.taglib.TagInfo;

public class _jet_listEntitys_0 implements JET2Template {
    private static final String _jetns_c = "org.eclipse.jet.controlTags"; //$NON-NLS-1$

    public _jet_listEntitys_0() {
        super();
    }

    private static final String NL = System.getProperty("line.separator"); //$NON-NLS-1$
    
    private static final TagInfo _td_c_get_1_28 = new TagInfo("c:get", //$NON-NLS-1$
            1, 28,
            new String[] {
                "select", //$NON-NLS-1$
            },
            new String[] {
                "uppercaseFirst($eachTable/@name)", //$NON-NLS-1$
            } );
    private static final TagInfo _td_c_get_20_31 = new TagInfo("c:get", //$NON-NLS-1$
            20, 31,
            new String[] {
                "select", //$NON-NLS-1$
            },
            new String[] {
                "uppercaseFirst($eachTable/@name)", //$NON-NLS-1$
            } );
    private static final TagInfo _td_c_get_20_161 = new TagInfo("c:get", //$NON-NLS-1$
            20, 161,
            new String[] {
                "select", //$NON-NLS-1$
            },
            new String[] {
                "uppercaseFirst($eachTable/@name)", //$NON-NLS-1$
            } );

    public void generate(final JET2Context context, final JET2Writer __out) {
        JET2Writer out = __out;
        out.write("    public static void list");  //$NON-NLS-1$        
        RuntimeTagElement _jettag_c_get_1_28 = context.getTagFactory().createRuntimeTag(_jetns_c, "get", "c:get", _td_c_get_1_28); //$NON-NLS-1$ //$NON-NLS-2$
        _jettag_c_get_1_28.setRuntimeParent(null);
        _jettag_c_get_1_28.setTagInfo(_td_c_get_1_28);
        _jettag_c_get_1_28.doStart(context, out);
        _jettag_c_get_1_28.doEnd();
        out.write("s(final Handler handler, final int what){");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("        final String url = Url;//相关，与后台Controller中url一致");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("        final Message msg = new Message();");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("        msg.what = what;");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("        final Bundle bundle = new Bundle();");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("        try{");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("            HttpUtil.getData(url, new Callback() {");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("                @Override");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("                public void onFailure(@NotNull Call call, @NotNull IOException e) {");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("                    if(e.getCause().equals(SocketTimeoutException.class)){");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("                        //do something while connect timeout");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("                    }");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("                    bundle.putInt(KeyData.resultCode,KeyData.RESULT_FAILURE);");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("                    msg.setData(bundle);");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("                    handler.sendMessage(msg);");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("                }");  //$NON-NLS-1$        
        out.write(NL);         
        out.write(NL);         
        out.write("                @Override");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("                public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("                    ArrayList<");  //$NON-NLS-1$        
        RuntimeTagElement _jettag_c_get_20_31 = context.getTagFactory().createRuntimeTag(_jetns_c, "get", "c:get", _td_c_get_20_31); //$NON-NLS-1$ //$NON-NLS-2$
        _jettag_c_get_20_31.setRuntimeParent(null);
        _jettag_c_get_20_31.setTagInfo(_td_c_get_20_31);
        _jettag_c_get_20_31.doStart(context, out);
        _jettag_c_get_20_31.doEnd();
        out.write("> result = new Gson().fromJson(response.body().string(),new TypeToken<ArrayList<");  //$NON-NLS-1$        
        RuntimeTagElement _jettag_c_get_20_161 = context.getTagFactory().createRuntimeTag(_jetns_c, "get", "c:get", _td_c_get_20_161); //$NON-NLS-1$ //$NON-NLS-2$
        _jettag_c_get_20_161.setRuntimeParent(null);
        _jettag_c_get_20_161.setTagInfo(_td_c_get_20_161);
        _jettag_c_get_20_161.doStart(context, out);
        _jettag_c_get_20_161.doEnd();
        out.write(">>(){}.getType());");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("                    bundle.putSerializable(KeyData.key,result);");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("                    bundle.putInt(KeyData.resultCode,KeyData.RESULT_SUCCESS);");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("                    msg.setData(bundle);");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("                    handler.sendMessage(msg);");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("                }");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("            });");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("        }catch (IOException e){");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("            //do something");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("        }");  //$NON-NLS-1$        
        out.write(NL);         
        out.write("    }");  //$NON-NLS-1$        
    }
}
